package pl.edu.agh.mbc.main;

import java.util.HashMap;

import org.apache.log4j.BasicConfigurator;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import pl.edu.agh.configs.ServerConfig;
import pl.edu.agh.mbc.database.dao.UserDaoImpl;
import pl.edu.agh.mbc.database.dao.commons.BaseDao;
import pl.edu.agh.mbc.database.dao.commons.DaoControll;
import pl.edu.agh.mbc.server.ServerRunner;

public class EntryPoint {
	private static XmlBeanFactory beanFactory;
	
	static{
		beanFactory = new XmlBeanFactory(new ClassPathResource(
        "config.xml"));
		
	}

	public void startApp() throws Exception{
		initialize();
	}
	
	private void initialize() throws Exception{
		ServerConfig serverConfig =  (ServerConfig)beanFactory.getBean("serverConfig");
		DaoControll daoControll = (DaoControll)beanFactory.getBean("daoControll");
		ServerRunner.init(daoControll, serverConfig);
		ServerRunner.getInstance().startServer();
	}
	
	public static void main(String[] args) throws Exception{
		BasicConfigurator.configure();
		EntryPoint ep = new EntryPoint();
		ep.startApp();
	}
}
